/**
 * @author Cheng Liu
 **/

#pragma once

#include "IPlugin.h"
#include "../Facade/PluginFacade.h"
#include <vector>
#include <map>
#include <string>
#include <Windows.h>

class PluginManagerBase {
protected:
	struct PluginInfo {
		std::basic_string<TCHAR> ModuleFileName;
		HMODULE ModuleHANDLE;
		std::string PluginName;
		int PluginVersion;
	};

	typedef std::map<HMODULE, PluginInfo*> moduleTable;
	typedef std::map<IPlugin*, PluginInfo*> pluginTable;
    PluginManagerBase();

public:
    virtual void Initialize() = 0;
    virtual ~PluginManagerBase();
    virtual void Destroy();

protected:

    HMODULE LoadModule(const TCHAR* FileName);
    bool ReleaseModule(HMODULE module);
    IPlugin* CreatePluginObject(HMODULE);
    bool DestroyPluginObject(IPlugin* plugin);
	
	bool ActivatePlugin(IPlugin * plugin);
	bool DeactivatePlugin(IPlugin * plugin);

protected:

    PluginFacade *cine; 
    moduleTable modules;
    pluginTable plugins;

};
